
import static org.junit.Assert.*;

import models.Encounter;
import models.Health;
import models.Ship;
import models.Player;
import org.junit.Test;

public class EncounterTest {

	final Player player = Player.getPlayer("Test", 5, 4, 3, 5);
	Encounter e = new Encounter(Encounter.Type.PIRATE,player);

	/**
	 * This test simply checks that the encounter is created correctly with respect to the player passed in
	 */
	@Test
	public void getPlayerTest() {
		System.out.println("Does player = e.getPlayer?");
		assertTrue("Does player = e.getPlayer?",e.getPlayer().equals(player));
		assertFalse("Player does not equal character",e.getCharacter().equals(player));
	}
	
	/**
	 * This test makes sure that the attack method works correctly; particularly for the pirate class;
	 * It also assumes that the defend function for the player class is functional
	 */
	@Test
	public void pirateAttackTest() {
		System.out.println("pirateAttackTest");
		assertTrue("Is Pirate attack >= 0?",e.getCharacter().attack() >= 0);
		int initialHealth = player.getShip().getHealth().getValue();
		player.defend(e.getCharacter().attack());
		
		assertFalse("Did player's health change?",player.getShip().getHealth().getValue() == (initialHealth));
	}
	/**
	 * This test is to make sure that the defend method for pirate works correctly
	 * As with the test above, it assumes that the Player attack method works correctly
	 */
	@Test
	public void pirateDefendTest() {
		System.out.println("pirateDefendTest");
		assertTrue("Is player attack >= 0",player.attack() >= 0);
		int initialHealth = ((Encounter.Pirate) e.getCharacter()).getShip().getHealth().getValue();
		e.getCharacter().defend(player.attack());
		assertFalse("Did Pirate health change?",((Encounter.Pirate) e.getCharacter()).getShip().getHealth().getValue() == (initialHealth));
	}

}
